# @Time : 2020/7/27 15:06
# @Author : Fioman 
# @Phone : 13149920693
import cv2 as cv
import numpy as np

"""
形态学梯度运算是用图像的膨胀图像减去腐蚀图像的操作,该操作可以获取原始图像中前景图像的边缘.
"""

img = cv.imread("test.bmp",cv.IMREAD_GRAYSCALE)
kernel = np.ones((5,5),dtype=np.uint8)
gradient = cv.morphologyEx(img,cv.MORPH_GRADIENT,kernel,iterations=1)

cv.imshow("Original",img)
cv.imshow("Gradient",gradient)

cv.waitKey(0)